from flask import Flask,session
from flask_session import Session
from flask_sqlalchemy import SQLAlchemy
import redis



app = Flask(__name__)
class Config(object):
    SECRET_KEY = "ASDADADD"
    SQLALCHEMY_DATABASE_URI = "mysql+pymsql://root:mysql@127.0.0.1:3306/information11"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    REDIS_HOST = "127.0.0.1"
    REDIS_POST = 6379

    # config.setdefault('SESSION_TYPE', 'null')
    # config.setdefault('SESSION_PERMANENT', True)
    # config.setdefault('SESSION_USE_SIGNER', False)
    # config.setdefault('SESSION_KEY_PREFIX', 'session:')
    # config.setdefault('SESSION_REDIS', None)
    SESSION_TYPE = "redis"
    SESSION_PERMANENT = True
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST,port=REDIS_POST)
    PERMANENT_SESSION_LIFETIME = 3600*24*2


app.config.from_object(Config)
db = SQLAlchemy(app)
redis_store = redis.StrictRedis(host=Config.REDIS_HOST,port=Config.REDIS_POST)
Session(app)

@app.route('/')
def index1():

    redis_store.set('name','zhangsan')
    session["age"] = "13"
    print(session.get("age"))

    return"helloworld10000"
if __name__ == "__main__":
    app.run(debug=True)
